<?php
/**
 * User: hjd-yao
 * Date: 2019/3/25
 * Time: 16:50
 */

namespace App\User;

use App\Helpers\Traits\HandleError;
use App\Models\User\UserAuthModel;
use App\Models\User\UserBaseModel;
use Carbon\Carbon;
use DC\UserCenter\Services\UserActivate;
use DC\UserCenter\Services\UserRegister;
use Illuminate\Http\Request;

class UserCenter
{
    use HandleError;
    public static function make()
    {
        return new static();
    }

    public function registerByAdmin(Request $request)
    {
        $user_register = new UserRegister();
        $response = $user_register->register($request);
        if(!$response['status']){
            $this->errorMsg = $response['errorMsg'];
            return false;
        }
        return true;
    }

    public function activatedByAdmin($id)
    {
       $user_activate = new UserActivate();
       $response = $user_activate->activating($id);
        if(!$response['status']){
            $this->errorMsg = $response['errorMsg'];
            return false;
        }
        return true;
    }

    public function EmptyActivatedUser($id)
    {
        $user_activate = new UserActivate();
        $response = $user_activate->EmptyActivating($id);
        if(!$response['status']){
            $this->errorMsg = $response['errorMsg'];
            return false;
        }
        return true;
    }


    public function activatedByUser($id,$activated_id)
    {
        $user_activate = new UserActivate();
        $response = $user_activate->activatingByUser($id,$activated_id);
        if(!$response['status']){
            $this->errorMsg = $response['errorMsg'];
            return false;
        }
        return true;
    }


    public function freeze($id,$freeze_cause)
    {
        $user_activate = new UserActivate();
        $response = $user_activate->freezing($id,$freeze_cause);
        if(!$response['status']){
            $this->errorMsg = $response['errorMsg'];
            return false;
        }
        return true;
    }

    public function unfreeze($id)
    {
        $user_activate = new UserActivate();
        $response = $user_activate->unfreezing($id);
        if(!$response['status']){
            $this->errorMsg = $response['errorMsg'];
            return false;
        }
        return true;
    }

    public function edit($input_data,$id,$action)
    {
        $user_register = new UserRegister();
        $response = $user_register->edit($input_data,$id,$action);
        if(!$response['status']){
            $this->errorMsg = $response['errorMsg'];
            return false;
        }
        return true;
    }
}